/**
 * 
 */
package com.unsanctioned.radioagregator.http;

import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.json.JSONObject;

import android.util.Log;

/**
 * @author wizard
 *
 */
public class HttpRequestThreadPool {
	private static List<String> ThreadNameRegister = new LinkedList<String>();
	private static Thread daemon = null;
	public static final String DOGTAG = HttpRequestThreadPool.class.getSimpleName();
	public static interface HttpRequestInterface {
		public void onHttpRequestFinished(String data);
		public void onHttpRequestFailed(String data);
	}
	public static enum ThreadFunction {
		CLIENT_LOGIN,
		USER_LOGIN,
		USER_LOGOUT,
		PODCAST,
		SEARCH,
	}
	public static void CallThreadDaemon() {
		daemon = new Thread(new Runnable() {
			
			@Override
			public void run() {
				// TODO Auto-generated method stub
				while (true) {
					for (String threadNameOnRegister: ThreadNameRegister) {

					}
					try {
						Thread.sleep(5000);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}
			}
		}, "ThreadNameRegisterDaemon");
		daemon.setDaemon(true);
		daemon.run();
	}
	public static Thread createThread(String name, ThreadFunction threadFunction, JSONObject properties) {
		if (ThreadNameRegister.contains(name)) {
			Log.i(DOGTAG, "Thread with this name already exists. Please choose another name.");
			return null;
		}
		Thread thread = null; 
		Object runnable = null;
		final JSONObject finProperties = properties;
		if (threadFunction.equals(ThreadFunction.CLIENT_LOGIN)) {
			runnable = new Runnable() {
				public void run() {
					 
				}
			};
		} else if (threadFunction.equals(ThreadFunction.USER_LOGIN)) {
		} else if (threadFunction.equals(ThreadFunction.USER_LOGOUT)) {
		} else if (threadFunction.equals(ThreadFunction.PODCAST)) {
		} else if (threadFunction.equals(ThreadFunction.SEARCH)) {
		}
		return thread;
	}
	public static Thread getDaemon() {
		return daemon;
	}
}
